﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExtendPropertyLib;
using System.Collections.ObjectModel;
using EnvDTE;
namespace ExORMDesginer.Models
{
    /// <summary>
    /// 保存解决方案下项目信息路径的抽象类
    /// </summary>
    public class ProjectItemInfo : BusinessInfoBase<ProjectItemInfo>
    {

        public ProjectItemInfo()
        {
            ProjectItemInfoList = new ObservableCollection<ProjectItemInfo>();
        }


        public static ExtendProperty ProjectItemInfoListProperty = RegisterProperty(m => m.ProjectItemInfoList);
        /// <summary>
        /// 子项目信息
        /// </summary>
        public ObservableCollection<ProjectItemInfo> ProjectItemInfoList
        {
            set
            {
                SetValue(ProjectItemInfoListProperty, value);
            }
            get
            {
                return (ObservableCollection<ProjectItemInfo>)GetValue(ProjectItemInfoListProperty);
            }
        }

        
        public static ExtendProperty TagProperty = RegisterProperty(m => m.Tag);
        /// <summary>
        /// 用于保存项目选项
        /// </summary>
        public object Tag
        {
            set
            {
                SetValue(TagProperty, value);
            }
            get
            {
                return (object)GetValue(TagProperty);
            }
        }

        /// <summary>
        /// 项目类型
        /// </summary>
        public ProjectItemType ItemType { set; get; }
        
        public static ExtendProperty NameProperty = RegisterProperty(m => m.Name);
        /// <summary>
        /// 名称
        /// </summary>
        public string Name
        {
            set
            {
                SetValue(NameProperty, value);
            }
            get
            {
                return (string)GetValue(NameProperty);
            }
        }

        
        public static ExtendProperty FullPathProperty = RegisterProperty(m => m.FullPath);
        /// <summary>
        /// 路径
        /// </summary>
        public string FullPath
        {
            set
            {
                SetValue(FullPathProperty, value);
            }
            get
            {
                return (string)GetValue(FullPathProperty);
            }
        }

        /// <summary>
        /// 将文件添加到项目目录中
        /// </summary>
        /// <param name="fileName"></param>
        public void AddFromFile(string fileName)
        {
            var items = Tag as ProjectItems;
            items.AddFromFileCopy(fileName);
        }

    }


    public enum ProjectItemType
    {
        Directory,
        Project
    }

}
